<template>
	 <mdp-table :subOpType="currOpType" :multiple="multiple" :operWidth="currOpType=='select'?0:220" :params="{tableName:modelValue,dataSource:dataSource}"  ref="tableFieldListRef" :columnCfgs="columnCfgs" :crudApis="crudApis" @select="(v)=>$emit('select',v)"/>
</template> 
<script> 
import {getTableColumnList,addTableColumn,batchDelTableColumn,delTableColumn,editSomeFieldsTableColumn} from '@/api/mdp/dm/meta'
export default {
	name: 'TableFieldList', 
	props: {
		modelValue: {
			type:[String,Array,Object],
			default:function(){
				return null
			}
		},
		dataSource:{
			type:String,
			default:'master'
		}, 
		subOpType:{
			type:String,
			default: 'mng'
		},
		multiple:{
			type: Boolean,
			default: false
		}
	},
	data(){
		return {  
			columnCfgs:[
				
			  {label:'字段名称',property:'columnName'},
			  {label:'字段描述',property:'remarks'},
			  {label:'字段类型',property:'dataTypeName'},
			  {label:'字段长度',property:'columnSize'},
				{label:'表名',property:'tableName'}, 
			],
			crudApis:{
				list:getTableColumnList,
				add: addTableColumn,
				del: delTableColumn,
				batchDel: batchDelTableColumn,
				editSomeFields: editSomeFieldsTableColumn
			}
		}
	},
	computed: {
		currOpType(){
			return this.subOpType
		},
		value:{
			set(val){
				this.$emit('update:modelValue',val)
			},
			get(){
				return this.modelValue
			}
		}
	}, 
	methods:{ 
		doSearch(){  
			if(!this.value){
				return;
			}
			this.$refs['tableFieldListRef']?.searchTableDatas();
		}
	},
	mounted() { 
	}
}
</script>
